Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Enable the SNS_Topic tests #519

Closed
wants to merge 2 commits into from

Conversation

tremble
Copy link
Contributor

@tremble tremble commented Apr 2, 2021

SUMMARY

Enable the SNS topic tests
split from #489 because sns_topic tests appear to be slightly unstable

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

sns_topic

ADDITIONAL INFORMATION

https://app.shippable.com/github/ansible-collections/community.aws/runs/2148/19/tests
https://app.shippable.com/github/ansible-collections/community.aws/runs/2148/22/tests

03:23 TASK [sns_topic : unsubscribe from third party topic (purge_subscription defaults to true)] ***
03:24 ok: [testhost] => {"changed": false, "resource_actions": ["sns:ListSubscriptionsByTopic", "sns:ListSubscriptions", "sns:ListTopics"], "sns_arn": "arn:aws:sns:us-east-1:806199016981:AmazonIpSpaceChanged", "sns_topic": {"attributes_set": [], "check_mode": false, "name": "arn:aws:sns:us-east-1:806199016981:AmazonIpSpaceChanged", "state": "present", "subscriptions": [], "subscriptions_added": [], "subscriptions_deleted": [], "subscriptions_existing": [], "subscriptions_new": [], "subscriptions_purge": true, "topic_created": false, "topic_deleted": false}}
03:24 
03:24 TASK [sns_topic : assert that unsubscribing from third party topic works] ******
03:25 fatal: [testhost]: FAILED! => {
03:25     "assertion": "third_party_unsubscribe.changed",
03:25     "changed": false,
03:25     "evaluated_to": false,
03:25     "msg": "Assertion failed"
03:25 }
04:01 task path: /root/ansible_collections/community/aws/tests/output/.tmp/integration/sns_topic-vlun4oz6-ÅÑŚÌβŁÈ/tests/integration/targets/sns_topic/tasks/main.yml:177
04:01 <testhost> ESTABLISH LOCAL CONNECTION FOR USER: root
04:01 <testhost> EXEC /bin/sh -c 'echo ~root && sleep 0'
04:01 <testhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /root/.ansible/tmp `"&& mkdir "` echo /root/.ansible/tmp/ansible-tmp-1617367528.607524-1574-37727407118341 `" && echo ansible-tmp-1617367528.607524-1574-37727407118341="` echo /root/.ansible/tmp/ansible-tmp-1617367528.607524-1574-37727407118341 `" ) && sleep 0'
04:01 Using module file /root/ansible_collections/community/aws/plugins/modules/sns_topic.py
04:01 <testhost> PUT /root/.ansible/tmp/ansible-local-11453shnc_u3/tmp8ttu6fnf TO /root/.ansible/tmp/ansible-tmp-1617367528.607524-1574-37727407118341/AnsiballZ_sns_topic.py
04:01 <testhost> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1617367528.607524-1574-37727407118341/ /root/.ansible/tmp/ansible-tmp-1617367528.607524-1574-37727407118341/AnsiballZ_sns_topic.py && sleep 0'
04:01 <testhost> EXEC /bin/sh -c 'ANSIBLE_DEBUG_BOTOCORE_LOGS=True /usr/bin/python3.7 /root/.ansible/tmp/ansible-tmp-1617367528.607524-1574-37727407118341/AnsiballZ_sns_topic.py && sleep 0'
04:02 <testhost> EXEC /bin/sh -c 'rm -f -r /root/.ansible/tmp/ansible-tmp-1617367528.607524-1574-37727407118341/ > /dev/null 2>&1 && sleep 0'
04:02 changed: [testhost] => {
04:02     "changed": true,
04:02     "invocation": {
04:02         "module_args": {
04:02             "aws_access_key": "ASIA6CCDWXDOKIJGUTOA",
04:02             "aws_ca_bundle": null,
04:02             "aws_config": null,
04:02             "aws_secret_key": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
04:02             "debug_botocore_endpoint_logs": true,
04:02             "delivery_policy": null,
04:02             "display_name": "My new topic name",
04:02             "ec2_url": null,
04:02             "name": "shippable-2148-19-topic",
04:02             "policy": null,
04:02             "profile": null,
04:02             "purge_subscriptions": false,
04:02             "region": "us-east-1",
04:02             "security_token": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
04:02             "state": "present",
04:02             "subscriptions": [
04:02                 {
04:02                     "endpoint": "arn:aws:lambda:us-east-1:966509639900:function:shippable-2148-19-sns_topic_lambda:2",
04:02                     "protocol": "lambda"
04:02                 }
04:02             ],
04:02             "validate_certs": true
04:02         }
04:02     },
04:02     "resource_actions": [
04:02         "sns:Subscribe",
04:02         "sns:GetTopicAttributes",
04:02         "sns:ListTopics",
04:02         "sns:ListSubscriptionsByTopic"
04:02     ],
04:02     "sns_arn": "arn:aws:sns:us-east-1:966509639900:shippable-2148-19-topic",
04:02     "sns_topic": {
04:02         "attributes_set": [],
04:02         "check_mode": false,
04:02         "delivery_policy": "{\"http\":{\"defaultHealthyRetryPolicy\":{\"minDelayTarget\":40,\"maxDelayTarget\":40,\"numRetries\":6,\"numMaxDelayRetries\":0,\"numNoDelayRetries\":0,\"numMinDelayRetries\":0,\"backoffFunction\":\"linear\"},\"disableSubscriptionOverrides\":false}}",
04:02         "display_name": "My new topic name",
04:02         "name": "shippable-2148-19-topic",
04:02         "owner": "966509639900",
04:02         "policy": "{\"Version\":\"2012-10-17\",\"Id\":\"SomePolicyId\",\"Statement\":[{\"Sid\":\"ANewSid\",\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"arn:aws:iam::966509639900:root\"},\"Action\":\"sns:Subscribe\",\"Resource\":\"arn:aws:sns:us-east-1:966509639900:shippable-2148-19-topic\",\"Condition\":{\"StringEquals\":{\"sns:Protocol\":\"email\"}}}]}",
04:02         "state": "present",
04:02         "subscriptions": [],
04:02         "subscriptions_added": [
04:02             [
04:02                 "lambda",
04:02                 "arn:aws:lambda:us-east-1:966509639900:function:shippable-2148-19-sns_topic_lambda:2"
04:02             ]
04:02         ],
04:02         "subscriptions_confirmed": "0",
04:02         "subscriptions_deleted": "0",
04:02         "subscriptions_existing": [],
04:02         "subscriptions_new": [
04:02             {
04:02                 "endpoint": "arn:aws:lambda:us-east-1:966509639900:function:shippable-2148-19-sns_topic_lambda:2",
04:02                 "protocol": "lambda"
04:02             }
04:02         ],
04:02         "subscriptions_pending": "0",
04:02         "subscriptions_purge": false,
04:02         "topic_arn": "arn:aws:sns:us-east-1:966509639900:shippable-2148-19-topic",
04:02         "topic_created": false,
04:02         "topic_deleted": false
04:02     }
04:02 }
04:02 
04:02 TASK [sns_topic : assert that subscribing worked] ******************************
04:02 task path: /root/ansible_collections/community/aws/tests/output/.tmp/integration/sns_topic-vlun4oz6-ÅÑŚÌβŁÈ/tests/integration/targets/sns_topic/tasks/main.yml:184
04:02 fatal: [testhost]: FAILED! => {
04:02     "assertion": "sns_topic_subscribe.sns_topic.subscriptions|length == 1",
04:02     "changed": false,
04:02     "evaluated_to": false,
04:02     "msg": "Assertion failed"
04:02 }

@ansibullbot
Copy link

@ansibullbot ansibullbot added WIP Work in progress bug This issue/PR relates to a bug integration tests/integration needs_triage plugins plugin (any type) python3 small_patch Hopefully easy to review tests tests labels Apr 2, 2021
@tremble
Copy link
Contributor Author

tremble commented May 21, 2021

recheck

@ansibullbot ansibullbot removed the small_patch Hopefully easy to review label May 21, 2021
@tremble
Copy link
Contributor Author

tremble commented Aug 7, 2021

Already fixed in #599

@tremble tremble closed this Aug 7, 2021
@tremble tremble deleted the tests/sns_topic branch November 26, 2021 12:44
abikouo pushed a commit to abikouo/community.aws that referenced this pull request Oct 24, 2023
Fix support envvars for lookup aws ssm

SUMMARY

Took over from ansible-collections#623 to apply reviewer's comments and add a changelog fragment.
Working on support in lookup plugin amazon.aws.aws_ssm for endpoint parameters, as well of tradional environment variable for client configuration (AWS_PROFILE, AWS_ACCESS_KEY_ID, ...).
This should fixes ansible-collections#519
Depends-On: ansible-collections#728
ISSUE TYPE

Feature Pull Request

COMPONENT NAME
aws_ssm
ADDITIONAL INFORMATION
It seems LookupModule cannot benefit from AnsibleAWSModule (it expect several methods/params, I am not familiar enough with Python and Ansible to sort it out) ; so this PR uses boto3_conn and get_aws_connection_info defined in utils.ec2.
This is a simple snippet how it can be used:
- name: Load env
  collections:
  - amazon.aws
  gather_facts: no
  hosts: localhost
  connection: local
  vars:
    my_env: "{{ lookup('amazon.aws.aws_ssm', 'status', endpoint='http://localhost:4566') }}"
  tasks:
    - name: show the env
      debug:
        msg: "{{ my_env }}"

Command line test:
ANSIBLE_COLLECTIONS_PATHS=${ANSIBLE_HOME}/collections ansible-playbook test.yml
Output:
PLAY [Load env] *************************************************************************************************************************************************************************************************************************************************************

TASK [show the env] *********************************************************************************************************************************************************************************************************************************************************
ok: [localhost] => {
    "msg": "INIT"
}

PLAY RECAP ******************************************************************************************************************************************************************************************************************************************************************
localhost                  : ok=1    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   

Another test with envars:
AWS_ACCESS_KEY_ID='foo' AWS_ACCESS_SECRET_KEY='bar' AWS_URL='http://localhost:4566' ANSIBLE_COLLECTIONS_PATHS=${ANSIBLE_HOME}/collections ansible-playbook test.yml
where we remove the endpoint from lookup:
- name: Load env
  collections:
  - amazon.aws
  gather_facts: no
  hosts: localhost
  connection: local
  vars:
    my_env: "{{ lookup('amazon.aws.aws_ssm', 'status') }}"
  tasks:
    - name: show the env
      debug:
        msg: "{{ my_env }}"
(provides same output)

Reviewed-by: Mark Chappell <None>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue/PR relates to a bug integration tests/integration plugins plugin (any type) python3 tests tests WIP Work in progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants